<template>
  <div class="">
    <van-nav-bar
      @click-left="$router.back()"
      left-arrow
      title="提交客户列表"
      fixed
    ></van-nav-bar>

    <van-search v-model="searchKey" shape="round" placeholder="搜索名称" />
    <main>
      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        :immediate-check="false"
        @load="onLoad"
      >
        <div class="item" v-for="item in formData" :key="item.id">
          <div class="top">
            <div class="left">
              <img :src="$publicObj.urlImg(item.img)" alt="" />
            </div>
            <div class="right">
              <h3>{{ item.name }}</h3>
              <div class="foot">
                <p>
                  <img src="../../assets/images/form/phone.png" alt="" />
                  {{ item.phone }}
                </p>
                <span>{{ item.gmtCreate }}</span>
              </div>
            </div>
          </div>
          <div class="bottom">来源：优联互通</div>
          <div class="badge">
            <img
              src="../../assets/images/form/visit.png"
              alt=""
              class="visit"
              v-if="item.responses"
            />
            <img
              src="../../assets/images/form/article.png"
              alt=""
              class="abp"
              v-if="item.tableType == 1"
            />
            <img
              src="../../assets/images/form/poster.png"
              alt=""
              class="abp"
              v-else-if="item.tableType == 3"
            />
            <img
              src="../../assets/images/form/video.png"
              alt=""
              class="abp"
              v-else
            />
          </div>
        </div>
      </van-list>
    </main>
  </div>
</template>

<script>
// 引入echarts
export default {
  name: "",
  data() {
    return {
      searchKey: "", //搜索关键字
      formData: [], //表单列表
      loading: false,
      finished: false,
      page: 1, //页数
      limit: 8, //条数
      totalPage: 100, //总页数
    };
  },
  //生命周期 - 创建完成（访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（访问DOM元素）
  mounted() {
    // document.querySelector("#app").style.backgroundColor = "#f3f5f7";
    this.getFormMessageInfo();
  },
  methods: {
    //触底下一页
    onLoad() {
      if (this.page >= this.totalPage) {
        this.finished = true;
        return;
      }
      this.page++;

      this.getFormMessageInfo();
      // 加载状态结束
      this.loading = false;
    },
    //获取表单列表
    async getFormMessageInfo() {
      let res = await this.$api.getFormMessageInfo({
        id: this.$route.query.id,
        page: this.page,
        limit: this.limit,
      });
      if (res.code !== 0) return;
      //判断是否是第一页
      if (this.page == 1) {
        this.formData = res.data.records || [];
      } else {
        this.formData.push(...res.data.records);
      }
      this.totalPage = res.data.pages;
    },
  },
};
</script>
<style scoped lang="less">
/* @import url(); 引入css类 */
.van-search {
  margin-top: 46px;
}
main {
  padding: 0 15px;
  height: calc(100vh - 100px);
  overflow-y: scroll;
  .item {
    position: relative;
    padding: 14px 8px 9px;
    background-color: #ffffff;
    border-radius: 5px;
    box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.06);
    margin-top: 12px;
    .top {
      display: flex;
      width: 100%;
      .left {
        img {
          width: 53px;
          height: 53px;
        }
      }
      .right {
        flex: 1;
        margin-left: 11px;
        display: flex;
        flex-direction: column;
        justify-content: space-around;

        h3 {
          font-size: 14px;
          color: #333333;
        }
        .foot {
          display: flex;
          align-items: center;
          justify-content: space-between;
          p {
            font-size: 11px;
            color: #666666;
            display: flex;
            align-items: center;
            img {
              width: 15px;
              height: 15px;
              margin-right: 5px;
            }
          }
          span {
            font-size: 10px;
            color: #999999;
          }
        }
      }
    }
    .bottom {
      margin-top: 10px;
      font-size: 11px;
      color: #666666;
    }
    .badge {
      position: absolute;
      top: 0;
      right: 3px;
      display: flex;
      .abp {
        width: 32px;
        height: 20px;
      }
      .visit {
        width: 44px;
        height: 19px;
        margin-right: 10px;
      }
    }
  }
}
</style>
